<?php
class UserAccountInfoForm extends BaseDmUserForm {
    public function configure() {
        unset (
                $this['username'],
                $this['last_login'],
                $this['created_at'],
                $this['updated_at'],
                $this['salt'],
                $this['algorithm'],
                $this['groups_list'],
                $this['permissions_list'],
                $this['is_active'],
                $this['is_super_admin'],
                $this['forgot_password_code']
        );
        $this->widgetSchema['password'] = new sfWidgetFormInputPassword(array(), array(
                        'autocomplete' => 'off'
        ));
        $this->validatorSchema['password']->setOption('required', $this->object->isNew());
        $this->widgetSchema['password_again'] = new sfWidgetFormInputPassword(array(
                        'label' => 'Password (again)'
                ), array(
                        'autocomplete' => 'off'
        ));
        $this->validatorSchema['password_again'] = clone $this->validatorSchema['password'];

        $this->widgetSchema->moveField('password_again', 'after', 'password');

        $this->mergePostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'password_again', array(), array('invalid' => 'The two passwords must be the same.')));
 

        $this->changeToEmail('email');
        $profileForm = new UserAccountProfileForm($this->object->getProfile());
        $this->embedForm('Profile', $profileForm);
    }
}